//店铺设置其他记录
import { useState, useEffect, useRef } from "react";
import CommonModal from "@/components/CommonModal";
import SearchContent from "./SearchContent";
import TableContent from "./TableContent";
import { Button } from "antd";

const OtherModifyRecordModal = ({ visible, handleCancel }) => {
	const [query, setQuery] = useState({});
	const [tableKey, setTableKey] = useState(0);
	const [loading, setloading] = useState(false);

	const divEl = useRef(null);

	useEffect(() => {
		if (visible) {
		}
	}, [visible]);

	const searchProps = {
		visible,
		query,
		handleSetQuery(val) {
			setQuery(val);
			setTableKey(tableKey + 1);
		},
		handleSearch(val) {
			if (val && Object.keys(val)?.length) {
				setQuery(val);
			} else {
				setQuery({});
			}
			setTableKey(tableKey + 1);
		}
	};

	const tableProps = {
		visible,
		tableKey,
		query,
		divEl
	};

	return (
		<CommonModal
			title="店铺设置其他记录"
			visible={visible}
			onCancel={handleCancel}
			width="930px"
			footer={
				<>
					<Button onClick={handleCancel}>关闭</Button>
				</>
			}
		>
			<div>
				<div ref={divEl}>
					<SearchContent {...searchProps} />
				</div>
				<TableContent {...tableProps} />
			</div>
		</CommonModal>
	);
};

export default OtherModifyRecordModal;
